import requests from './request';

//登录
export const loginInfo = (data) => requests({
    url: '/login.php',
    method: 'post',
    data
});

//退出登录
export const logoutInfo = (id) => requests({
    url: `/logout.php?id=${id}`,
    method: 'get'
});

//修改密码
export const updatepswInfo = ({ id, oldpsw, newpsw }) => requests({
    url: `/updatePassword.php?id=${id}&&oldpsw=${oldpsw}&&newpsw=${newpsw}`,
    method: 'get'
});

//获取类别
export const categoryInfo = () => requests({
    url: '/getCategory.php',
    method: 'get'
});

//获取书籍
export const booksinfo = (flag, cgName) => requests({
    url: `/getBooks.php?flag=${flag}&&cgName=${cgName}`,
    method: 'get'
});

//添加类别
export const addCategoryInfo = (data) => requests({
    url: '/addCategory.php',
    method: 'post',
    data
});

//编辑类别
export const updateCategoryInfo = (data) => requests({
    url: `/updateCategory.php`,
    method: 'post',
    data
});

//获取用户
export const getUsersInfo = (id, flag) => requests({
    url: `/getUsers.php?id=${id}&&flag=${flag}`,
    method: 'get'
});

//删除指定类别
export const deleteCategoryInfo = (id, cg) => requests({
    url: `/deleteCategory.php?id=${id}&&category=${cg}`,
    method: 'get'
});

//添加书籍
export const addBookInfo = (data) => requests({
    url: '/addBook.php',
    method: 'post',
    data
});

//删除书籍
export const deleteBookInfo = (id) => requests({
    url: `/deleteBookOrUser.php?id=${id}&&flag=book`,
    method: 'get'
});

//改变书籍借阅状态
export const changeBorrowStatusInfo = (id, status) => requests({
    url: `/changeBorrowStatus.php?id=${id}&&status=${status}`,
    method: 'get'
});

//编辑书籍
export const updateBookInfor = (data) => requests({
    method: 'post',
    url: '/updateBookInfo.php',
    data
});

//借阅管理
export const bookLendInfo = (data) => requests({
    url: '/bookAndUserLendInfo.php',
    method: 'post',
    data
});

//添加或编辑用户
export const addOrEditUserInfo = (data) => requests({
    url: "/addOrEditUser.php",
    method: 'post',
    data
});

//删除书籍
export const deleteUserInfo = (id) => requests({
    url: `/deleteBookOrUser.php?id=${id}&&flag=user`,
    method: 'get'
});

//通过borrowId获取借阅书籍
export const getBorrowBookInfo = (id) => requests({
    url: `/borrowBookIdGetBook.php?id=${id}`,
    method: 'get'
});

//忘记密码 
export const forgetPswOrEnrollAdminInfo = (data) => requests({
    url: `/forgetPasswordOrEnrollAdmin.php`,
    method: 'post',
    data
});


//借阅借阅归还书籍
export const userBorrowBookInfo = (data) => requests({
    url: `/bookLend.php`,
    method: 'post',
    data
});

